package com.ticket.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ticket.entity.Volunteer;
import com.ticket.mapper.VolunteerMapper;
import com.ticket.service.IVolunteerService;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;

@Service
public class VolunteerServiceImpl extends ServiceImpl<VolunteerMapper, Volunteer> implements IVolunteerService {
    
    @Override
    public List<Volunteer> getVolunteersByIds(String volunteerIds) {
        if (!StringUtils.hasText(volunteerIds)) {
            return new ArrayList<>();
        }
        
        List<Long> idList = Arrays.stream(volunteerIds.split(","))
                .map(String::trim)
                .filter(StringUtils::hasText)
                .map(Long::parseLong)
                .collect(Collectors.toList());
        
        if (idList.isEmpty()) {
            return new ArrayList<>();
        }
        
        return this.listByIds(idList);
    }
} 